package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Table;
import com.ruoyi.system.service.ITableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 翁大洪的表Controller
 * 
 * @author wdh
 * @date 2024-06-27
 */
@RestController
@RequestMapping("/system/table")
public class TableController extends BaseController
{
    @Autowired
    private ITableService tableService;

    /**
     * 查询翁大洪的表列表
     */
    @PreAuthorize("@ss.hasPermi('system:table:list')")
    @GetMapping("/list")
    public TableDataInfo list(Table table)
    {
        startPage();
        List<Table> list = tableService.selectTableList(table);
        return getDataTable(list);
    }

    /**
     * 导出翁大洪的表列表
     */
    @PreAuthorize("@ss.hasPermi('system:table:export')")
    @Log(title = "翁大洪的表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Table table)
    {
        List<Table> list = tableService.selectTableList(table);
        ExcelUtil<Table> util = new ExcelUtil<Table>(Table.class);
        util.exportExcel(response, list, "翁大洪的表数据");
    }

    /**
     * 获取翁大洪的表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:table:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tableService.selectTableById(id));
    }

    /**
     * 新增翁大洪的表
     */
    @PreAuthorize("@ss.hasPermi('system:table:add')")
    @Log(title = "翁大洪的表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Table table)
    {
        return toAjax(tableService.insertTable(table));
    }

    /**
     * 修改翁大洪的表
     */
    @PreAuthorize("@ss.hasPermi('system:table:edit')")
    @Log(title = "翁大洪的表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Table table)
    {
        return toAjax(tableService.updateTable(table));
    }

    /**
     * 删除翁大洪的表
     */
    @PreAuthorize("@ss.hasPermi('system:table:remove')")
    @Log(title = "翁大洪的表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tableService.deleteTableByIds(ids));
    }
}
